package com.autobet.services;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;

/**
 * Created by yangd on 2017-11-12.
 */
public class BetStatus {

    public static BigDecimal dx1_dieCount = new BigDecimal("0");
    public static BigDecimal dx1_preAmount = new BigDecimal("1");
    public static BigDecimal dx1_buyAmount = new BigDecimal("1");
    public static BigDecimal dx2_dieCount = new BigDecimal("0");
    public static BigDecimal dx2_preAmount = new BigDecimal("1");
    public static BigDecimal dx2_buyAmount = new BigDecimal("1");
    public static BigDecimal dx3_dieCount = new BigDecimal("0");
    public static BigDecimal dx3_preAmount = new BigDecimal("1");
    public static BigDecimal dx3_buyAmount = new BigDecimal("1");
    public static BigDecimal dx4_dieCount = new BigDecimal("0");
    public static BigDecimal dx4_preAmount = new BigDecimal("1");
    public static BigDecimal dx4_buyAmount = new BigDecimal("1");
    public static BigDecimal dx5_dieCount = new BigDecimal("0");
    public static BigDecimal dx5_preAmount = new BigDecimal("1");
    public static BigDecimal dx5_buyAmount = new BigDecimal("1");
    public static BigDecimal dx6_dieCount = new BigDecimal("0");
    public static BigDecimal dx6_preAmount = new BigDecimal("1");
    public static BigDecimal dx6_buyAmount = new BigDecimal("1");
    public static BigDecimal dx7_dieCount = new BigDecimal("0");
    public static BigDecimal dx7_preAmount = new BigDecimal("1");
    public static BigDecimal dx7_buyAmount = new BigDecimal("1");
    public static BigDecimal dx8_dieCount = new BigDecimal("0");
    public static BigDecimal dx8_preAmount = new BigDecimal("1");
    public static BigDecimal dx8_buyAmount = new BigDecimal("1");
    public static BigDecimal dx9_dieCount = new BigDecimal("0");
    public static BigDecimal dx9_preAmount = new BigDecimal("1");
    public static BigDecimal dx9_buyAmount = new BigDecimal("1");
    public static BigDecimal dx10_dieCount = new BigDecimal("0");
    public static BigDecimal dx10_preAmount = new BigDecimal("1");
    public static BigDecimal dx10_buyAmount = new BigDecimal("1");

    public static BigDecimal ds1_dieCount = new BigDecimal("0");
    public static BigDecimal ds1_preAmount = new BigDecimal("1");
    public static BigDecimal ds1_buyAmount = new BigDecimal("1");
    public static BigDecimal ds2_dieCount = new BigDecimal("0");
    public static BigDecimal ds2_preAmount = new BigDecimal("1");
    public static BigDecimal ds2_buyAmount = new BigDecimal("1");
    public static BigDecimal ds3_dieCount = new BigDecimal("0");
    public static BigDecimal ds3_preAmount = new BigDecimal("1");
    public static BigDecimal ds3_buyAmount = new BigDecimal("1");
    public static BigDecimal ds4_dieCount = new BigDecimal("0");
    public static BigDecimal ds4_preAmount = new BigDecimal("1");
    public static BigDecimal ds4_buyAmount = new BigDecimal("1");
    public static BigDecimal ds5_dieCount = new BigDecimal("0");
    public static BigDecimal ds5_preAmount = new BigDecimal("1");
    public static BigDecimal ds5_buyAmount = new BigDecimal("1");
    public static BigDecimal ds6_dieCount = new BigDecimal("0");
    public static BigDecimal ds6_preAmount = new BigDecimal("1");
    public static BigDecimal ds6_buyAmount = new BigDecimal("1");
    public static BigDecimal ds7_dieCount = new BigDecimal("0");
    public static BigDecimal ds7_preAmount = new BigDecimal("1");
    public static BigDecimal ds7_buyAmount = new BigDecimal("1");
    public static BigDecimal ds8_dieCount = new BigDecimal("0");
    public static BigDecimal ds8_preAmount = new BigDecimal("1");
    public static BigDecimal ds8_buyAmount = new BigDecimal("1");
    public static BigDecimal ds9_buyAmount = new BigDecimal("1");
    public static BigDecimal ds9_dieCount = new BigDecimal("0");
    public static BigDecimal ds9_preAmount = new BigDecimal("1");
    public static BigDecimal ds10_dieCount = new BigDecimal("0");
    public static BigDecimal ds10_preAmount = new BigDecimal("1");
    public static BigDecimal ds10_buyAmount = new BigDecimal("1");


    /**
     * 获取基数
     * @param type
     * @param NO
     * @return
     */
    public static BigDecimal getPreAmount(String type , String NO){
        BigDecimal value = new BigDecimal("0");
        if ( "dx".equals(type) ){

            if( NO.equals("1")){
                value = dx1_preAmount;
            }else if( NO.equals("2")){
                value = dx2_preAmount;
            }else if( NO.equals("3")){
                value = dx3_preAmount;
            }else if( NO.equals("4")){
                value = dx4_preAmount;
            }else if( NO.equals("5")){
                value = dx5_preAmount;
            }else if( NO.equals("6")){
                value = dx6_preAmount;
            }else if( NO.equals("7")){
                value = dx7_preAmount;
            }else if( NO.equals("8")){
                value = dx8_preAmount;
            }else if( NO.equals("9")){
                value = dx9_preAmount;
            }else if( NO.equals("10")){
                value = dx10_preAmount;
            }

        }else {
            if( NO.equals("1")){
                value = ds1_preAmount;
            }else if( NO.equals("2")){
                value = ds2_preAmount;
            }else if( NO.equals("3")){
                value = ds3_preAmount;
            }else if( NO.equals("4")){
                value = ds4_preAmount;
            }else if( NO.equals("5")){
                value = ds5_preAmount;
            }else if( NO.equals("6")){
                value = ds6_preAmount;
            }else if( NO.equals("7")){
                value = ds7_preAmount;
            }else if( NO.equals("8")){
                value = ds8_preAmount;
            }else if( NO.equals("9")){
                value = ds9_preAmount;
            }else if( NO.equals("10")){
                value = ds10_preAmount;
            }
        }
        return value;
    }

    /**
     * 获取穿版
     * @param type
     * @param NO
     * @return
     */
    public static BigDecimal getDieCount(String type , String NO){
        BigDecimal value = new BigDecimal("0");
        if ( "dx".equals(type) ){

            if( NO.equals("1")){
                value = dx1_dieCount;
            }else if( NO.equals("2")){
                value = dx2_dieCount;
            }else if( NO.equals("3")){
                value = dx3_dieCount;
            }else if( NO.equals("4")){
                value = dx4_dieCount;
            }else if( NO.equals("5")){
                value = dx5_dieCount;
            }else if( NO.equals("6")){
                value = dx6_dieCount;
            }else if( NO.equals("7")){
                value = dx7_dieCount;
            }else if( NO.equals("8")){
                value = dx8_dieCount;
            }else if( NO.equals("9")){
                value = dx9_dieCount;
            }else if( NO.equals("10")){
                value = dx10_dieCount;
            }

        }else {
            if( NO.equals("1")){
                value = ds1_dieCount;
            }else if( NO.equals("2")){
                value = ds2_dieCount;
            }else if( NO.equals("3")){
                value = ds3_dieCount;
            }else if( NO.equals("4")){
                value = ds4_dieCount;
            }else if( NO.equals("5")){
                value = ds5_dieCount;
            }else if( NO.equals("6")){
                value = ds6_dieCount;
            }else if( NO.equals("7")){
                value = ds7_dieCount;
            }else if( NO.equals("8")){
                value = ds8_dieCount;
            }else if( NO.equals("9")){
                value = ds9_dieCount;
            }else if( NO.equals("10")){
                value = ds10_dieCount;
            }
        }
        return value;
    }

    /**
     * 获取下注金额
     * @param type
     * @param NO
     * @return
     */
    public static BigDecimal getBuyAmount(String type , String NO){
        BigDecimal value = new BigDecimal("0");
        if ( "dx".equals(type) ){

            if( NO.equals("1")){
                value = dx1_buyAmount;
            }else if( NO.equals("2")){
                value = dx2_buyAmount;
            }else if( NO.equals("3")){
                value = dx3_buyAmount;
            }else if( NO.equals("4")){
                value = dx4_buyAmount;
            }else if( NO.equals("5")){
                value = dx5_buyAmount;
            }else if( NO.equals("6")){
                value = dx6_buyAmount;
            }else if( NO.equals("7")){
                value = dx7_buyAmount;
            }else if( NO.equals("8")){
                value = dx8_buyAmount;
            }else if( NO.equals("9")){
                value = dx9_buyAmount;
            }else if( NO.equals("10")){
                value = dx10_buyAmount;
            }

        }else {
            if( NO.equals("1")){
                value = ds1_buyAmount;
            }else if( NO.equals("2")){
                value = ds2_buyAmount;
            }else if( NO.equals("3")){
                value = ds3_buyAmount;
            }else if( NO.equals("4")){
                value = ds4_buyAmount;
            }else if( NO.equals("5")){
                value = ds5_buyAmount;
            }else if( NO.equals("6")){
                value = ds6_buyAmount;
            }else if( NO.equals("7")){
                value = ds7_buyAmount;
            }else if( NO.equals("8")){
                value = ds8_buyAmount;
            }else if( NO.equals("9")){
                value = ds9_buyAmount;
            }else if( NO.equals("10")){
                value = ds10_buyAmount;
            }
        }
        return value;
    }

    /**
     * 设置基数
     * @param type
     * @param NO
     * @param value
     */
    public static void setPreAmount(String type , String NO , BigDecimal value){
        if ( "dx".equals(type) ){

            if( NO.equals("1")){
                dx1_preAmount = value;
            }else if( NO.equals("2")){
                dx2_preAmount = value;
            }else if( NO.equals("3")){
                dx3_preAmount = value;
            }else if( NO.equals("4")){
                dx4_preAmount = value;
            }else if( NO.equals("5")){
                dx5_preAmount = value;
            }else if( NO.equals("6")){
                dx6_preAmount = value;
            }else if( NO.equals("7")){
                dx7_preAmount = value;
            }else if( NO.equals("8")){
                dx8_preAmount = value;
            }else if( NO.equals("9")){
                dx9_preAmount = value;
            }else if( NO.equals("10")){
                dx10_preAmount = value;
            }

        }else {
            if( NO.equals("1")){
                ds1_preAmount = value;
            }else if( NO.equals("2")){
                ds2_preAmount = value;
            }else if( NO.equals("3")){
                ds3_preAmount = value;
            }else if( NO.equals("4")){
                ds4_preAmount = value;
            }else if( NO.equals("5")){
                ds5_preAmount = value;
            }else if( NO.equals("6")){
                ds6_preAmount = value;
            }else if( NO.equals("7")){
                ds7_preAmount = value;
            }else if( NO.equals("8")){
                ds8_preAmount = value;
            }else if( NO.equals("9")){
                ds9_preAmount = value;
            }else if( NO.equals("10")){
                ds10_preAmount = value;
            }
        }
    }


    /**
     * 设置穿版
     * @param type
     * @param NO
     * @param value
     */
    public static void setDieCount(String type , String NO , BigDecimal value){

        if ( "dx".equals(type) ){

            if( NO.equals("1")){
                dx1_dieCount = value;
            }else if( NO.equals("2")){
                dx2_dieCount = value;
            }else if( NO.equals("3")){
                dx3_dieCount = value;
            }else if( NO.equals("4")){
                dx4_dieCount = value;
            }else if( NO.equals("5")){
                dx5_dieCount = value;
            }else if( NO.equals("6")){
                dx6_dieCount = value;
            }else if( NO.equals("7")){
                dx7_dieCount = value;
            }else if( NO.equals("8")){
                dx8_dieCount = value;
            }else if( NO.equals("9")){
                dx9_dieCount = value;
            }else if( NO.equals("10")){
                dx10_dieCount = value;
            }

        }else {
            if( NO.equals("1")){
                ds1_dieCount = value;
            }else if( NO.equals("2")){
                ds2_dieCount = value;
            }else if( NO.equals("3")){
                ds3_dieCount = value;
            }else if( NO.equals("4")){
                ds4_dieCount = value;
            }else if( NO.equals("5")){
                ds5_dieCount = value;
            }else if( NO.equals("6")){
                ds6_dieCount = value;
            }else if( NO.equals("7")){
                ds7_dieCount = value;
            }else if( NO.equals("8")){
                ds8_dieCount = value;
            }else if( NO.equals("9")){
                ds9_dieCount = value;
            }else if( NO.equals("10")){
                ds10_dieCount = value;
            }
        }
    }

    /**
     * 设置下注金额
     * @param type
     * @param NO
     * @param value
     */
    public static void setBuyAmount(String type , String NO , BigDecimal value){

        if ( "dx".equals(type) ){

            if( NO.equals("1")){
                dx1_buyAmount = value;
            }else if( NO.equals("2")){
                dx2_buyAmount = value;
            }else if( NO.equals("3")){
                dx3_buyAmount = value;
            }else if( NO.equals("4")){
                dx4_buyAmount = value;
            }else if( NO.equals("5")){
                dx5_buyAmount = value;
            }else if( NO.equals("6")){
                dx6_buyAmount = value;
            }else if( NO.equals("7")){
                dx7_buyAmount = value;
            }else if( NO.equals("8")){
                dx8_buyAmount = value;
            }else if( NO.equals("9")){
                dx9_buyAmount = value;
            }else if( NO.equals("10")){
                dx10_buyAmount = value;
            }

        }else {
            if( NO.equals("1")){
                ds1_buyAmount = value;
            }else if( NO.equals("2")){
                ds2_buyAmount = value;
            }else if( NO.equals("3")){
                ds3_buyAmount = value;
            }else if( NO.equals("4")){
                ds4_buyAmount = value;
            }else if( NO.equals("5")){
                ds5_buyAmount = value;
            }else if( NO.equals("6")){
                ds6_buyAmount = value;
            }else if( NO.equals("7")){
                ds7_buyAmount = value;
            }else if( NO.equals("8")){
                ds8_buyAmount = value;
            }else if( NO.equals("9")){
                ds9_buyAmount = value;
            }else if( NO.equals("10")){
                ds10_buyAmount = value;
            }
        }
    }

    /**
     * 获取最大穿版
     * @return
     */
    public static BigDecimal getMaxDieCount(){
        JSONArray statusArray = new JSONArray();
        BigDecimal value = new BigDecimal("0");
        statusArray = getAllStatus();
        for(int i = 0 ; i < statusArray.size() ; i++){

            if(value.compareTo(new BigDecimal(statusArray.getJSONObject(i).get("dieCount").toString())) == -1  ){
                value = new BigDecimal(statusArray.getJSONObject(i).get("dieCount").toString());
            }
        }
        return value;
    }

    /**
     * 获取所有状态
     * @return
     */
    public static JSONArray getAllStatus(){
        JSONArray statusArray = new JSONArray();
        JSONObject statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","1");
        statusObject.put("dieCount",dx1_dieCount);
        statusObject.put("preAmount",dx1_preAmount);
        statusObject.put("buyAmount",dx1_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","2");
        statusObject.put("dieCount",dx2_dieCount);
        statusObject.put("preAmount",dx2_preAmount);
        statusObject.put("buyAmount",dx2_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","3");
        statusObject.put("dieCount",dx3_dieCount);
        statusObject.put("preAmount",dx3_preAmount);
        statusObject.put("buyAmount",dx3_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","4");
        statusObject.put("dieCount",dx4_dieCount);
        statusObject.put("preAmount",dx4_preAmount);
        statusObject.put("buyAmount",dx4_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","5");
        statusObject.put("dieCount",dx5_dieCount);
        statusObject.put("preAmount",dx5_preAmount);
        statusObject.put("buyAmount",dx5_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","6");
        statusObject.put("dieCount",dx6_dieCount);
        statusObject.put("preAmount",dx6_preAmount);
        statusObject.put("buyAmount",dx6_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","7");
        statusObject.put("dieCount",dx7_dieCount);
        statusObject.put("preAmount",dx7_preAmount);
        statusObject.put("buyAmount",dx7_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","8");
        statusObject.put("dieCount",dx8_dieCount);
        statusObject.put("preAmount",dx8_preAmount);
        statusObject.put("buyAmount",dx8_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","9");
        statusObject.put("dieCount",dx9_dieCount);
        statusObject.put("preAmount",dx9_preAmount);
        statusObject.put("buyAmount",dx9_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","dx");
        statusObject.put("NO","10");
        statusObject.put("dieCount",dx10_dieCount);
        statusObject.put("preAmount",dx10_preAmount);
        statusObject.put("buyAmount",dx10_buyAmount);
        statusArray.add(statusObject);

        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","1");
        statusObject.put("dieCount",ds1_dieCount);
        statusObject.put("preAmount",ds1_preAmount);
        statusObject.put("buyAmount",ds1_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","2");
        statusObject.put("dieCount",ds2_dieCount);
        statusObject.put("preAmount",ds2_preAmount);
        statusObject.put("buyAmount",ds2_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","3");
        statusObject.put("dieCount",ds3_dieCount);
        statusObject.put("preAmount",ds3_preAmount);
        statusObject.put("buyAmount",ds3_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","4");
        statusObject.put("dieCount",ds4_dieCount);
        statusObject.put("preAmount",ds4_preAmount);
        statusObject.put("buyAmount",ds4_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","5");
        statusObject.put("dieCount",ds5_dieCount);
        statusObject.put("preAmount",ds5_preAmount);
        statusObject.put("buyAmount",ds5_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","6");
        statusObject.put("dieCount",ds6_dieCount);
        statusObject.put("preAmount",ds6_preAmount);
        statusObject.put("buyAmount",ds6_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","7");
        statusObject.put("dieCount",ds7_dieCount);
        statusObject.put("preAmount",ds7_preAmount);
        statusObject.put("buyAmount",ds7_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","8");
        statusObject.put("dieCount",ds8_dieCount);
        statusObject.put("preAmount",ds8_preAmount);
        statusObject.put("buyAmount",ds8_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","9");
        statusObject.put("dieCount",ds9_dieCount);
        statusObject.put("preAmount",ds9_preAmount);
        statusObject.put("buyAmount",ds9_buyAmount);
        statusArray.add(statusObject);
        statusObject = new JSONObject();
        statusObject.put("type","ds");
        statusObject.put("NO","10");
        statusObject.put("dieCount",ds10_dieCount);
        statusObject.put("preAmount",ds10_preAmount);
        statusObject.put("buyAmount",ds10_buyAmount);
        statusArray.add(statusObject);

        return statusArray;
    }
}
